<?php
class Default_Form_Object extends Zend_Form
{
    public $allPlugins;
    
    public function __construct()
    {
        parent::__construct($options);
        $this->setName('Object');

        $this->addElement('hidden', 'id');

        $this->addElement('text', 'name', array(
            'label'      => 'Objekta nosaukums:',
            'required'   => true,
            'filters'    => array(
                'StripTags',
                'StringTrim'
            ),
            'validators' => array(
                'NotEmpty'
                )
            )
        );

        $controller = Zend_Controller_Front::getInstance();
        $db = $controller->getParam('bootstrap')->getResource('db');
        $tables = $db->fetchPairs("SHOW TABLES LIKE 'plugin_%'");
        if(is_array($tables)){
            foreach($tables AS $table => $val){
                $plugins[$table] = str_replace('plugin_', '', $table);
            }
        }

        $this->allPlugins = $plugins;

        $this->addElement('multiselect', 'plugin',
            array(
                'label'     => 'Spraudņi:',
                'filters'   => array('StringTrim', 'StripTags'),
                'required'  => false,
                'MultiOptions' => $plugins,
                'value'   => $selected,
                'class' => 'multiselect',
                'multiple' => 'multiple',
            )
        );

        $this->addElement('submit', 'submit', array(
            'ignore'   => true,
            'label'    => 'Saglabāt',
        ));

    }

}
